<template>
	<view class="content">
		<yzbClassification
			ref="yzb"
			:list="types"
			:index="index"
			:selectedColor="color"
			:type1LineHeight="lineheight1"
			:type1Size="size1"
			:type2Size="size2"
			:type3Size="size3"
			:type1Height="heigth1"
			@selectType="select"
		></yzbClassification>
	</view>
</template>

<script>
import yzbClassification from '@/components/yzb/yzb-classification.vue';
export default {
	components: {
		yzbClassification
	},
	data() {
		return {
			types: [],
			index: 0,
			color: '#84C0F4',
			size1: '12px',
			size2: '14px',
			size3: '10px',
			heigth1: '90rpx',
			lineheight1: '90rpx',
			Typevalue:'',//类型
			// type11: []
			professionName:''
		};
	},
	onLoad(option) {
		this.getTypes();
		this.Typevalue = option.Typevalue
		if(this.Typevalue == 1){			
			this.getDetail()
		}
	},
	methods: {
		async getDetail(){
			var that = this
			let res= await this.$apis.getResumeDetail(uni.getStorageSync('wxuser_id'));
			if(res.msg =="操作成功"){
				/* let conveArr = res.data.expJobList.map(d=>{
					 return d.professionName
				}) */
				this.professionName = conveArr.join(',')
			}
		},
		async getTypes() {
			var that = this
			let res = await this.$apis.getProfessionList();
			if(res){
				this.types = res.data
				this.types = that.$toTreeData.toTreeData(
				    res.data,					
					'professionId',
					'professionPId'   
				);
				for(var i= 0;i<this.types.length;i++){
					var p = this.types[i].children
					for(var v= 0;v<p.length;v++){
						this.types[i].children[v].selected=false
					}
				}
			}			
			this.$refs.yzb.init();
		},

		select(n1, n2, n3) {
			var that = this
			console.log('点击传来的值为', n1, n2, n3);
			console.log('点击的值为', this.types[n1].children[n2].children[n3].professionId);
			if(that.Typevalue == 1){//用户职位
				this.$page.prePage().jobDetail.professionName = this.types[n1].children[n2].children[n3].professionName;
				this.$page.prePage().jobDetail.professionId = this.types[n1].children[n2].children[n3].professionId;
			}else if(this.Typevalue == 3){//工作经历
				this.$page.prePage().workData.workTitle = this.types[n1].children[n2].children[n3].professionName;
				this.$page.prePage().workData.professionId = this.types[n1].children[n2].children[n3].professionId;
			}else{//企业职位
				this.$page.prePage().position.jobName = this.types[n1].children[n2].children[n3].professionName;//企业职位	
				this.$page.prePage().position.professionId = this.types[n1].children[n2].children[n3].professionId;//企业职位	
			}
			uni.navigateBack({
				delta:1
			})
		}
	}
};
</script>

<style></style>
